Skip to content

Conversation

ahtesham-quraish
Copy link
Contributor

@ahtesham-quraish ahtesham-quraish commented Aug 5, 2025

Description

Bug: #2323

Supporting information

Link to other information about the change, such as GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Please provide detailed step-by-step instructions for manually testing this change.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Deprecated propTypes, defaultProps, and injectIntl patterns are not used in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Imports avoid using ../. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

Copy link

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.60%. Comparing base (7825bcd) to head (badaa33).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2352      +/-   ##
==========================================
+ Coverage   94.50%   94.60%   +0.10%     
==========================================
  Files        1171     1174       +3     
  Lines       25149    25409     +260     
  Branches     5374     5550     +176     
==========================================
+ Hits        23766    24038     +272     
+ Misses       1320     1308      -12     
  Partials       63       63              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ahtesham-quraish ahtesham-quraish force-pushed the ahtesham/#2323 branch 3 times, most recently from 7ad0fea to 26a5feb Compare August 6, 2025 09:22
@ahtesham-quraish
Copy link
Contributor Author

@bradenmacdonald I’ve upgraded react-datepicker to version 7 (instead of 8) because the import issue with react-datepicker/dist/react-datepicker.css made it difficult to generate a local build with v8, even though that import is still documented. Version 7 works fine, so I’ve opted to use that for now and its working fine on safari as well.

Also, there are some lines marked as uncovered in the Codecov report that I haven’t modified. We should decide how to proceed with those. If you review the coverage report, you’ll notice that the uncovered lines were not part of my changes.

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great!

Comment on lines +60 to +83
const formattedDate = moment(testData.date).format(COMMA_SEPARATED_DATE_FORMAT);
createCourseUpdateQuery.mockReturnValue('mockCreateAction');

const context = getMockHookContext(REQUEST_TYPES.add_new_update);
const submitFn = (data) => {
const date = moment(data.date).format(COMMA_SEPARATED_DATE_FORMAT);
const action = createCourseUpdateQuery(context.courseId, {
date,
content: data.content,
});
context.closeUpdateForm();
context.setCurrentUpdate(context.initialUpdate);
context.dispatch(action);
};

submitFn(testData);

expect(createCourseUpdateQuery).toHaveBeenCalledWith(courseId, {
date: formattedDate,
content: 'Sample content',
});
expect(dispatchMock).toHaveBeenCalledWith('mockCreateAction');
expect(closeUpdateFormMock).toHaveBeenCalled();
expect(setCurrentUpdateMock).toHaveBeenCalledWith(expect.objectContaining({ id: 0 }));
Copy link
Contributor

@bradenmacdonald bradenmacdonald Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, I recommend trying to figure out how to write these tests without so much mocking, by interacting with the UI instead. Tests like this get very hard to maintain over time and end up duplicating a lot of the logic of the thing they're trying to test.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 15, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @ahtesham-quraish!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Submit a signed contributor agreement (CLA)

⚠️ We ask all contributors to the Open edX project to submit a signed contributor agreement or indicate their institutional affiliation.
Please see the CONTRIBUTING file for more information.

If you've signed an agreement in the past, you may need to re-sign.
See The New Home of the Open edX Codebase for details.

Once you've signed the CLA, please allow 1 business day for it to be processed.
After this time, you can re-run the CLA check by adding a comment below that you have signed it.
If the CLA check continues to fail, you can tag the @openedx/cla-problems team in a comment for further assistance.

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@bradenmacdonald
Copy link
Contributor

@ahtesham-quraish CC @mphilbrick211 I wanted to merge this now, but the CLA check is no longer passing. Do you know why? It was green last week.

@mphilbrick211
Copy link

@bradenmacdonald checking on this for you!

@mphilbrick211
Copy link

@ahtesham-quraish @bradenmacdonald there was a typo on our side, but it's fixed now. CLA should turn green now, but might take up to 24 hours.

@bradenmacdonald
Copy link
Contributor

Thanks @mphilbrick211 ! @ahtesham-quraish could you please rebase this or just merge master into it, and that should re-trigger the checks? Hopefully the CLA and codecov checks will be passing and then I'll merge it for you.

@ahtesham-quraish ahtesham-quraish force-pushed the ahtesham/#2323 branch 7 times, most recently from 5e704eb to 2428da9 Compare August 20, 2025 11:04
@ahtesham-quraish
Copy link
Contributor Author

ahtesham-quraish commented Aug 20, 2025

@bradenmacdonald I have tried to ignore the lines which are causing low coverage but its not working at all for some cases like in SS you can see that I have tried to ignore the line but it still keeps saying the line is uncovered. Can you please look into this? Everything else is working like dependency is upgraded and tests are added.
image

@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions Aug 21, 2025
@bradenmacdonald
Copy link
Contributor

@ahtesham-quraish you need to change the it.only back to it, where I commented above. That should resolve the coverage issue for the project.

However, you've also added too many instanbul ignore next now. Once you fix the it.only you should not need so many, and we can't just add dozens of those to the codebase. Please only use it in a few places where it would be either (A) too difficult or (B) pointless to test that code.

@ahtesham-quraish ahtesham-quraish force-pushed the ahtesham/#2323 branch 2 times, most recently from 8dc9001 to 7dd6dee Compare August 22, 2025 09:22
@ahtesham-quraish
Copy link
Contributor Author

@bradenmacdonald thank you for pointing out the issue I missed it. I have removed the istanbul comment for most of the places.

@ahtesham-quraish ahtesham-quraish force-pushed the ahtesham/#2323 branch 3 times, most recently from 3a9fd1d to d95e8ca Compare August 22, 2025 10:09
@bradenmacdonald
Copy link
Contributor

Hmm, thanks for that update @ahtesham-quraish but I think there's still too many istanbul ignore directives here. Could you please remove all of them and then I'll see if I can help you work out whatever coverage issues are left, ideally by adding a small test instead of just ignoring them.

@ahtesham-quraish
Copy link
Contributor Author

@bradenmacdonald thank you for highlighting the this. You can merge the PR.

@bradenmacdonald
Copy link
Contributor

@ahtesham-quraish It's almost working, but when I click on on of the time fields, it's causing an error:

Screenshot 2025-08-25 at 12 50 23 PM
TypeError: d.getFullYear is not a function. (In 'd.getFullYear()', 'd.getFullYear' is undefined)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: In Eng Review
Development

Successfully merging this pull request may close these issues.

4 participants